<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  
   <base href="<%=basePath%>">
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  <link rel="stylesheet" href="css/demos.css" type="text/css"></link>
  <link rel="stylesheet" href="css/jquery.ui.all.css" type="text/css"></link>
  <link rel="stylesheet" href="css/jquery.ui.theme.css" type="text/css"></link>
  <link rel="stylesheet" href="css/jquery.ui.base.css" type="text/css"></link>
  <script type="text/javascript" src="javascript/jquery-1.4a2.min.js"></script>
  </head>
  
  <body>
  
  	<script language="JavaScript" type="text/JavaScript">
    
    function callAjax(){
    	var url = "<%=basePath%>user.do?m=login";
    	var redurl = "<%=basePath%>loginSuccess.jsp";
    	
    	
    	$.ajax({ 
    		url: "<%=basePath%>user.do?m=login", 
    		data: {name:$("#tbemail").val(),password:$("#tbpassword").val()}, 
    		dataType:"html", 
    		success: function(data){
       			alert(data);
       			
				 if(data=="success"){
				 alert("succes")
		    		window.location.href = redurl;
		    		}else{
		    		 alert("fail")
		    			$("#checkname").append(data);
		    	}
      }});
    	
    }
    
   </script>

    <form >
    	用户名:<input type="text" id="tbemail" name="tbemail"  />
    	<label id ="checkname"> </label><br>
    	密   &nbsp     码:<input type="text" id= "tbpassword" name="tbpassword"/> <br>
    	           <input type="button" value="登录" onclick="callAjax()"/>
   </form>
    
    <br>
     
  </body>

</html>
